################ basic configration ################

cmake_minimum_required(VERSION 3.1)
project(DART_VISION)

set(CMAKE_CXX_STANDARD 17)
#Debug mode
#set (CMAKE_BUILD_TYPE "Debug")
#set (CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g2 -ggdb")
#set (CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
add_definitions(-DUVC_CONFIG="${CMAKE_SOURCE_DIR}/src/libuvc/UsbCapture.yaml")
################ build options ################

#依赖基本库 opencv libjpeg-turbo wiringpi
include_directories(/opt/libjpeg-turbo/include)
link_libraries(/opt/libjpeg-turbo/lib32/libturbojpeg.so)

#include_directories(/usr/include)
find_path(WIRINGPI_INCLUDE_DIRS NAMES wiringPi.h)
find_path(WIRINGPI_INCLUDE_DIRS NAMES wiringSerial.h)
find_library(WIRINGPI_LIBRARIES NAMES wiringPi)


find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(include)

file(GLOB_RECURSE LIB_UVC
        src/libuvc/UVCCamera.cpp
        )
add_library(UVCCamera SHARED ${LIB_UVC})
target_link_libraries(UVCCamera  ${OpenCV_LIBS})

# 查找多线程库（pthread）
find_package(Threads REQUIRED)
# 指定头文件目录（根据项目结构自行调整）
include_directories(${PROJECT_SOURCE_DIR}/src/libusart/Inc)

# 收集源文件（默认src目录下的所有.cpp文件）
set(SerialC++_SRCS ${PROJECT_SOURCE_DIR}/src/libusart/Src/serial_C++.cpp)
# 创建共享库
add_library(Seriallib SHARED ${SerialC++_SRCS})

add_executable(record src/main.cpp src/AsyncVideoWriter.cpp)
target_link_libraries(record UVCCamera)


target_link_libraries(record ${WIRINGPI_LIBRARIES} wiringPi)
# 链接多线程库和 Seriallib 库
target_link_libraries(record Threads::Threads Seriallib)
#target_link_libraries(record ${WIRINGPI_LIBRARIES} wiringPi pthread)
